

#include "msg_e1.h"
#include "page_base.h"
#include "img_common.h"
#include "sys_scene.h"
#include "pt_ipc.h"
#include "pt_info.h"
#include "pt_dev.h"
#include "sys_font.h"
#include "pt_fs.h"


static ui_msg_e1_t  ui_msg_e1;

static  char * icon_msg_e1[1] = 
{
    "Warning.png",
};

static int msg_e1_reboot_clicked_event(void)
{
    debug_d("reboot\n");

    pt_reboot();

    return 0;
}

static void msg_e1_reboot_event_callback(lv_event_t* event)
{
    if (event->code == LV_EVENT_CLICKED)
    {
        msg_e1_reboot_clicked_event();
    }
}

static int msg_e1_telephone_clicked_event(void)
{
    debug_d("telephone\n");
    
    pop_win_unload();
    pop_win_load("msg_tele",lv_page_msg_telephone_create());
    

    return 0;
}

static void msg_e1_telephone_event_callback(lv_event_t* event)
{
    if (event->code == LV_EVENT_CLICKED)
    {
        msg_e1_telephone_clicked_event();
    }
}


int ui_msg_e1_create(lv_obj_t *superview)
{
    char txt_buff[256];
    
    ui_msg_e1.img_tip = lv_img_create(superview);
    lv_img_set_src(ui_msg_e1.img_tip,pt_fs_get(icon_msg_e1[0]));
    lv_obj_set_pos(ui_msg_e1.img_tip,200,52);
    //**********************************************************************************************
    ui_msg_e1.lab_tip = lv_label_create(superview);
    lv_obj_set_pos(ui_msg_e1.lab_tip,24,156);
    lv_obj_set_size(ui_msg_e1.lab_tip,432,40);
    lv_obj_set_style_text_align(ui_msg_e1.lab_tip,LV_TEXT_ALIGN_CENTER,0);
    lv_obj_set_style_text_opa(ui_msg_e1.lab_tip,LV_OPA_100,LV_PART_MAIN);
    lv_obj_set_style_text_color(ui_msg_e1.lab_tip,lv_color_make(0xff,0xff,0xff),LV_PART_MAIN); 
    lv_obj_set_style_text_font(ui_msg_e1.lab_tip, lv_font_get(20), LV_STATE_DEFAULT);
    lv_label_set_text( ui_msg_e1.lab_tip, "E1故障：按键故障");
    //**********************************************************************************************
    // btn

    ui_msg_e1.bg_close = lv_obj_create(superview);

    lv_obj_set_pos(ui_msg_e1.bg_close,34,246);
    lv_obj_set_size(ui_msg_e1.bg_close,170,50);

	lv_obj_set_style_radius(ui_msg_e1.bg_close, 25, LV_PART_MAIN);
	lv_obj_set_style_border_width(ui_msg_e1.bg_close, 0, LV_PART_MAIN);
	lv_obj_set_style_border_color(ui_msg_e1.bg_close, lv_color_make(0x00, 0x00, 0x00), LV_PART_MAIN);
	lv_obj_set_style_border_opa(ui_msg_e1.bg_close, LV_OPA_0, LV_PART_MAIN);

	lv_obj_set_style_outline_width(ui_msg_e1.bg_close, 0, LV_PART_MAIN);
	lv_obj_set_style_shadow_width(ui_msg_e1.bg_close, 0, LV_PART_MAIN);
	lv_obj_set_scrollbar_mode(ui_msg_e1.bg_close, LV_SCROLLBAR_MODE_OFF);
	lv_obj_set_style_pad_all(ui_msg_e1.bg_close, 0,0);
    
    #if 0
    lv_obj_set_style_bg_opa(ui_msg_e1.bg_close,LV_OPA_0,0);
    #else
    lv_obj_set_style_bg_opa(ui_msg_e1.bg_close,LV_OPA_100,0);
    lv_obj_set_style_bg_color(ui_msg_e1.bg_close,lv_color_make(0x26,0x7a,0xff),0);
    #endif 

    lv_obj_add_event_cb(ui_msg_e1.bg_close, msg_e1_reboot_event_callback, LV_EVENT_ALL, NULL);
    //**********************************************************************************************
    ui_msg_e1.lab_close = lv_label_create(ui_msg_e1.bg_close);
    lv_obj_set_pos(ui_msg_e1.lab_close,0,11);
    lv_obj_set_size(ui_msg_e1.lab_close,170,30);
    lv_obj_set_style_text_align(ui_msg_e1.lab_close,LV_TEXT_ALIGN_CENTER,0);
    lv_obj_set_style_text_opa(ui_msg_e1.lab_close,LV_OPA_100,LV_PART_MAIN);
    lv_obj_set_style_text_color(ui_msg_e1.lab_close,lv_color_make(0xff,0xff,0xff),LV_PART_MAIN); 
    lv_obj_set_style_text_font(ui_msg_e1.lab_close, lv_font_get(28), LV_STATE_DEFAULT);

    lv_label_set_text(ui_msg_e1.lab_close,"重启设备");
    //**********************************************************************************************
    //**********************************************************************************************
    // btn

    ui_msg_e1.bg_try = lv_obj_create(superview);

    lv_obj_set_pos(ui_msg_e1.bg_try,249,246);
    lv_obj_set_size(ui_msg_e1.bg_try,170,50);

	lv_obj_set_style_radius(ui_msg_e1.bg_try, 25, LV_PART_MAIN);
	lv_obj_set_style_border_width(ui_msg_e1.bg_try, 0, LV_PART_MAIN);
	lv_obj_set_style_border_color(ui_msg_e1.bg_try, lv_color_make(0x00, 0x00, 0x00), LV_PART_MAIN);
	lv_obj_set_style_border_opa(ui_msg_e1.bg_try, LV_OPA_0, LV_PART_MAIN);

	lv_obj_set_style_outline_width(ui_msg_e1.bg_try, 0, LV_PART_MAIN);
	lv_obj_set_style_shadow_width(ui_msg_e1.bg_try, 0, LV_PART_MAIN);
	lv_obj_set_scrollbar_mode(ui_msg_e1.bg_try, LV_SCROLLBAR_MODE_OFF);
	lv_obj_set_style_pad_all(ui_msg_e1.bg_try, 0,0);
    
    #if 0
    lv_obj_set_style_bg_opa(ui_msg_e1.bg_try,LV_OPA_0,0);
    #else
    lv_obj_set_style_bg_opa(ui_msg_e1.bg_try,LV_OPA_100,0);
    lv_obj_set_style_bg_color(ui_msg_e1.bg_try,lv_color_make(0x26,0x7a,0xff),0);
    #endif 

    lv_obj_add_event_cb(ui_msg_e1.bg_try, msg_e1_telephone_event_callback, LV_EVENT_ALL, NULL);
    //**********************************************************************************************
    ui_msg_e1.lab_try = lv_label_create(ui_msg_e1.bg_try);
    lv_obj_set_pos(ui_msg_e1.lab_try,0,11);
    lv_obj_set_size(ui_msg_e1.lab_try,170,30);
    lv_obj_set_style_text_align(ui_msg_e1.lab_try,LV_TEXT_ALIGN_CENTER,0);
    lv_obj_set_style_text_opa(ui_msg_e1.lab_try,LV_OPA_100,LV_PART_MAIN);
    lv_obj_set_style_text_color(ui_msg_e1.lab_try,lv_color_make(0xff,0xff,0xff),LV_PART_MAIN); 
    lv_obj_set_style_text_font(ui_msg_e1.lab_try, lv_font_get(28), LV_STATE_DEFAULT);

    lv_label_set_text(ui_msg_e1.lab_try,"联系售后");
    //**********************************************************************************************


    return 0;
}


static void msg_e1_on_custom_attr_config(page_base_t* self)
{


}
static void msg_e1_on_view_load(page_base_t* self)
{


}
static void msg_e1_on_view_did_load(page_base_t* self)
{
    ui_msg_e1_create(self->root);

}
static void msg_e1_on_view_will_appear(page_base_t* self)
{


}
static void msg_e1_on_view_did_appear(page_base_t* self)
{


}
static void msg_e1_on_view_will_disappear(page_base_t* self)
{


}
static void msg_e1_on_view_did_disappear(page_base_t* self)
{


}
static void msg_e1_on_view_did_unload(page_base_t* self)
{


}

static page_vtable_t page_msg_e1_param = {

    .on_custom_attr_config  = msg_e1_on_custom_attr_config,
    .on_view_load           = msg_e1_on_view_load,
    .on_view_did_load       = msg_e1_on_view_did_load,
    .on_view_will_appear    = msg_e1_on_view_will_appear,
    .on_view_did_appear     = msg_e1_on_view_did_appear,
    .on_view_will_disappear = msg_e1_on_view_will_disappear,
    .on_view_did_disappear  = msg_e1_on_view_did_disappear,
    .on_view_did_unload     = msg_e1_on_view_did_unload,
};


page_vtable_t* lv_page_msg_e1_create(void)
{
    return &page_msg_e1_param;
}
